<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2007-4-15
  Time: 15:02:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<% int LENGTH = 10;%>
<html>
<head><title>Simple jsp page</title>
    <meta content="text/html;charset=UTF-8"/>
    <script type="text/javascript">
        function totalSum() {
            var sum = 0;
        <%for (int i=0 ; i<LENGTH ; i++){%>
            var values = document.getElementsByName("t<%=i%>")[0];
            if (values.value != "") {
                sum = sum +parseInt(values.value);
            }
        <%}%>
           document.getElementsByName("shows")[0].value=sum;
        }

        function changeScore(){
            var shows=document.getElementsByName("shows")[0];
            var parents=shows.parentNode.parentNode.getElementsByTagName()[0];
            alert(parents.id);
            show.focus();
        }
    </script>
</head>
<body>
<table>

    <%for (int i = 0; i < LENGTH; i++) {%>
    <tr>
        <td><input type="text" name="t<%=i%>" onchange="totalSum()"/></td>
    </tr>
    <%}%>
    <tr>
        <td><input type="button" name="button" value="计算" onclick="changeScore()"/></td>
    </tr>
    <tr>
        <td id="kkk">
            <input name="shows" type="text" value=""/>
        </td>
    </tr>

</table>
</body>
</html>